#ifndef XPM_EDITOR_H_INCLUDED
#define XPM_EDITOR_H_INCLUDED

#include <sdk.h>
#include <M_Code_plugin.h>
#include <wx/msgdlg.h>
#include "XPMEditorPanel.h"
#include "XPMEditorBase.h"
#include "XPMCustomZoom.h"
#include "XPMUndo.h"
#include <wx/wxprec.h>

#define XPM_DEFAULT_WIDTH   100
#define XPM_DEFAULT_HEIGHT  100
#define XPM_MAX_UNDO        100


class XPMEditor : public cbMimePlugin {
  public:
    XPMEditor();
    virtual ~XPMEditor();
    virtual void BuildMenu( wxMenuBar* menuBar ) {}
    virtual void BuildModuleMenu( const ModuleType type, wxMenu* menu, const FileTreeData* data = 0 ) {}
    virtual bool BuildToolBar( wxToolBar* toolBar ) { return false; }
    static XPMEditor* Get( void );
    bool OpenInEditor( wxString Filename );
    virtual bool CanHandleFile( const wxString& filename ) const;
    virtual int OpenFile( const wxString& filename );
    virtual bool HandlesEverything() const;
    bool DeleteEditor( XPMEditorBase *editor );
    void SetMaxUndoRedo( int iMax );
    int GetMaxUndoRedo( void );
    void SetDefaultImageSize( int iWidth, int iHeight );
    void GetDefaultImageSize( int *iWidth, int *iHeight );
    bool SetColourArray( wxColour *array, int inbColours,wxColour cTransparentColour );
    void GetColourArray( wxColour *array, int *inbColours,wxColour *cTransparentColour );
    wxColour GetBackGroundColour( void );
    void SetBackGroundColour( wxColour cBackColour );
    bool ReadConfiguration( bool bDefault );
    bool WriteConfiguration( void );
    void UpdateConfiguration( void );

  protected:
    virtual void OnAttach();
    virtual void OnRelease( bool appShutDown );

  private:
    static XPMEditor* m_Singleton;
    void CloseMyEditors( void );
    ProjectFile* FindProjectFile( const wxString& FileName );
    int iMaxUndoRedo;
    int iXPMDefaultWidth;
    int iXPMDefaultHeight;
    int iOpenXPM;
    wxColour *DefaultColourArray;
    wxColour cTransparent;
    int iNbColours;
    wxColour cBackgroundColour;
};

inline XPMEditor* XPM_Plugin() { return XPMEditor::Get(); }

#endif
